home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Macintosh Drag and Drop / Demo Applications / DragsAndLists / DrawCode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-04  |  2.3 KB  |  120 lines  |  [TEXT/MPS ]

  1.  
  2. #if defined(UseDumpFiles)
  3.     #include <DumpHeader.h>
  4. #endif
  5.  
  6.  
  7.  
  8. #include <Windows.h>
  9. #include <QuickDraw.h>
  10. #include <TextUtils.h>
  11. #include <Fonts.h>
  12.  
  13. #include "DragSupport.h"
  14. #include "ListCode.h"
  15.  
  16.  
  17. WindowPtr    gWindow;
  18.  
  19. /*------------------------------------------------------------------*/
  20.  
  21. void DrawIt(WindowPtr win)
  22. {    
  23. #pragma unused (win)
  24. }
  25.  
  26.  
  27. /*------------------------------------------------------------------*/
  28.  
  29. pascal void DrawWindowContent(short pixelDepth, short dFlags, GDHandle theDevice, long theWin)
  30. {
  31. #pragma unused (pixelDepth, dFlags, theDevice)
  32.     GrafPtr        savePort;
  33.  
  34.     GetPort(&savePort);
  35.     SetPort((GrafPtr)theWin);
  36.  
  37.     DrawIt((WindowPtr)theWin);
  38.     UpdateSourceList();
  39.     UpdateDestList();
  40.  
  41.     SetPort(savePort);
  42. }
  43.  
  44.  
  45. /*------------------------------------------------------------------*/
  46.  
  47. void CreateNewWindow(void)
  48. {
  49.     Rect winDimension;
  50.     GrafPtr        oldPort;
  51.  
  52.     SetRect(&winDimension, 60, 60, 320, 280);
  53.     gWindow = NewCWindow(0L, &winDimension, "\pSample", true, noGrowDocProc,
  54.                             (WindowPtr)-1L, true, 0L);
  55.  
  56.     GetPort(&oldPort);
  57.     SetPort(gWindow);
  58.     TextFont(courier);
  59.     TextFace(bold);
  60.     TextSize(12);
  61.     
  62.     BuildSourceList(gWindow);
  63.     AddToSourceList('roop');
  64.     AddToSourceList('ROOP');
  65.     AddToSourceList('Scop');
  66.     AddToSourceList('ytyy');
  67.     AddToSourceList('MACS');
  68.     AddToSourceList('yty1');
  69.     AddToSourceList('MAC1');
  70.     AddToSourceList('MAC2');
  71.     AddToSourceList('yty2');
  72.     AddToSourceList('MAC2');
  73.     AddToSourceList('3oop');
  74.     AddToSourceList('3OOP');
  75.     AddToSourceList('3cop');
  76.     AddToSourceList('3tyy');
  77.     AddToSourceList('3ACS');
  78.  
  79.     BuildDestList(gWindow);
  80.  
  81.     (void) InstallDragHandlers(gWindow);
  82.  
  83.     SetPort(oldPort);
  84. }
  85.  
  86.  
  87. /*------------------------------------------------------------------*/
  88.  
  89. void PreEventLoop(void)
  90. {
  91.     CreateNewWindow();
  92. }
  93.  
  94.  
  95. /*------------------------------------------------------------------*/
  96.  
  97. void DoUpdate(WindowPtr thisWindow)
  98. {
  99.     static DeviceLoopDrawingUPP    procForDeviceLoop = nil;
  100.  
  101.     SetPort(thisWindow);
  102.  
  103.     if ( procForDeviceLoop == nil )
  104.         procForDeviceLoop = NewDeviceLoopDrawingProc(DrawWindowContent);    
  105.     
  106.     BeginUpdate(thisWindow);
  107.     DeviceLoop(thisWindow->visRgn, procForDeviceLoop, (long)thisWindow, singleDevices);
  108.     EndUpdate(thisWindow);
  109. }
  110.  
  111.  
  112. /*------------------------------------------------------------------*/
  113.  
  114. void PostEventLoop(void)
  115. {
  116.     if (gWindow != NULL)
  117.         RemoveDragHandlers(gWindow);
  118. }
  119.  
  120.